<%@ page import="com.po.Note" %>
<%@ page isErrorPage="true"%>
<%@ page import="java.util.List" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    HttpSession session1 = request.getSession(false);
    String envelope_name = null;
    int envelope_id = (int) session.getAttribute("envelope_id");
    if (session1 == null || session1.getAttribute("id") == null) {
        response.sendRedirect(request.getContextPath() + "/index.jsp");
    } else {
        envelope_name = (String) session1.getAttribute("envelope_name");
    }
%>
<h3><%=envelope_name%>的纸条如下:</h3>
<table>
    <tr>
        <td>纸条名字</td>
        <td>纸条内容</td>
        <td>创建时间</td>
        <td>获赞数量</td>
        <td>引用内容</td>
        <td>删除信封</td>
    </tr>
    <%
        List<Note> notes = (List<Note>) request.getAttribute("notes");
        if (!notes.isEmpty()) {
            for (Note note : notes) {
    %>
    <tr>
        <td><%=note.getNote_name()%></td>
        <td><%=note.getContent()%></td>
        <td><%=note.getCreate_time()%></td>
        <td><%=note.getPriase_number()%></td>
        <%
            if(!"无".equals(note.getQuote())){
        %>
        <td><a href="<%=request.getContextPath()%>/quoteNote?content=<%=note.getQuote()%>"><%=note.getQuote()%>
        </a>
        </td>
        <%
            }else{
        %>
        <td></td>
        <%
            }
        %>
        <td><button onclick="window.location.href='<%=request.getContextPath()%>/function/selectMyComment?note_id=<%=note.getNote_id()%>&note_content=<%=note.getContent()%>&note_name=<%=note.getNote_name()%>'"
                type="button">我的评论区
        </button></td>
        <td><a onclick="return warning()" href="<%=request.getContextPath()%>/modify/deleteNote?note_id=<%=note.getNote_id()%>&envelope_id=<%=envelope_id%>&envelope_name=<%=envelope_name%>">删除</a></td>
    </tr>
    <%
            }
        }
    %>
</table>
<style>
    table {
        width: 650px;
        margin: auto;
        border: pink 1px solid;
        border-spacing: 0px;
        border-collapse: collapse;
    }

    td {
        border: pink 1px solid;
    }
</style>
<hr>
<a href="<%=request.getContextPath()%>/note/createNote.jsp">创建纸条</a><br>
<a href="<%=request.getContextPath()%>/exitNote">返回信封</a>

<style>
    body{
        background-image: url("../picture/new.jpg");
        background-repeat: no-repeat;
        background-attachment: fixed;
        background-position: center center;
        background-size: 100% 100%;
    }
</style>
<script>
    function warning(){
        if(confirm('确认要删除吗')==true){
            return true;
        }else{
            return false;
        }
    }
</script>